package com.example.myapplication.activity.base_activity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.myapplication.R;

public class ButtonEnableActivity extends AppCompatActivity implements View.OnClickListener {
    private Button test;
    private  TextView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_button_enable);
        Button enable = findViewById(R.id.btn_enable);
        enable.setOnClickListener(this);
        Button disable = findViewById(R.id.btn_disable);
        disable.setOnClickListener(this);
        test = findViewById(R.id.btn_test);
        test.setOnClickListener(this);
        tv = findViewById(R.id.tv_result);


    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.btn_enable) {
                test.setEnabled(true);
        } else if (view.getId() == R.id.btn_disable) {
            test.setEnabled(false);

        } else if (view.getId() == R.id.btn_test) {
            tv.setText(String.format("按钮已启用现在是 %s",System.currentTimeMillis()));

        }
    }
}